import logging
from redis import StrictRedis

"""定义一个配置类"""
class Config(object):
	DEBUG = True
	SECRET_KEY = "SASDASKD;LAKSD;LKA"

	SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@localhost:3306/flask_xyy"  #连接数据库
	SQLALCHEMY_TRACK_MODIFICATIONS = False   # 压制警告信息
	SQLALCHEMY_COMMIT_ON_TEARDOWN = True  # 当数据完成时自动提交

	REDIS_HOST = "127.0.0.1"  # redis 的ip　
	REDIS_PORT = 6379

	SESSION_TYPE = "redis"   # 设置session 存储类型为redis
	SESSION_USE_SIGNER = True  # 签名存储
	SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)  # 设置session存储对象
	PERMANENT_SESSION_LIFETIME = 3600*24*2  # 设置session 保存时间　为两天

	LEVEL = logging.DEBUG
"""开发环境模式"""
class DevelopConfig(Config):
	pass
"""生产环境模式（上线）"""
class ProductConfig(Config):
	DEBUG = False
	LEVEL = logging.ERROR
"""测试环境模式"""
class TestingConfig(Config):
	TESTING = True

"""通过字典统一访问配置类"""
config_dict = {
	"develop":DevelopConfig,
	"product":ProductConfig,
	"testing":TestingConfig
}



